#!/bin/bash

# 设置Java 17环境变量
export JAVA_HOME=/usr/local/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

echo "✅ 已切换到Java 17"
echo "Java版本: $(java -version 2>&1 | head -n 1)"
echo "JAVA_HOME: $JAVA_HOME"

# 执行传入的命令
if [ $# -eq 0 ]; then
    echo "使用方法: source use-java17.sh [命令]"
    echo "例如: source use-java17.sh mvn spring-boot:run"
else
    echo "执行命令: $@"
    exec "$@"
fi 